<template>
	<!-- 打包核销订单查询 -->
	<view class="packOrder">
		<view class="selectOrderList-date">
			<text class="time">{{resultData.start}}</text>
			<text class="centerText">至</text>
			<text class="time">{{resultData.end}}</text>
		</view>
		<none v-if="resultData.list.length==0"></none>
		<view class="selectOrderList-main" v-else>
			<view class="content" v-for="(item,index) in resultData.list" :key="index">
				<view class="endTime">
					完成时间：{{item.finishtime}}
				</view>
				<view class="selectOrderList-center">
					<view class="listItems">
						<text class="line">————</text>
						核验清单
						<text class="line">————</text>
					</view>
					<view class="tobePacked-type" v-for="(i,k) in item.content" :key="k">
						<view class="type-title">{{i.firstVal}},{{i.secondVal}}</view>
						<view class="type-content">
							<view class="content-number num">数量：{{i.number}}{{i.unit}}</view>
							<view class="content-number">回收币：{{i.user_price}}<text>/</text>{{i.unit}}</view>
							<view>小计：{{i.price}}回收币</view>
						</view>
					</view>
				</view>
				<view class="finishedMain-type-footer">
					<view class="finishedMain-total">
						<text class="finishedMain-title">收入-</text>
						<text class="value">{{item.collector_total}}回收币</text>
					</view>
					<view class="finishedMain-total">
						<text class="finishedMain-title">利润-</text>
						<text class="value">{{item.collector_profit}}回收币</text>
					</view>
				</view>
			</view>
			<nomore v-if="!hasMore"></nomore>
			<view v-else class="loading">加载中...</view>
		</view>
	</view>
</template>

<script>
	import util from '../../component/commen/api/util';
	import none from "@/otherPages/none/none.vue"
	import nomore from "@/component/noMore.vue"
	export default {
		components: {
			none,
			nomore
		},
		data() {
			return {
				type: "",
				startDate: "", //开始日期
				endDate: "", //结束日期
				resultData: { //查询结果
					list: []
				},
				page:1,//页
				psize:5,//每页条数
				hasMore:true,//是否还有更多数据
				list:[],
			};
		},
		onLoad(e) {
			this.type = e.type
			this.startDate = e.startDate
			this.endDate = e.endDate
		},
		onShow() {
			this.getQuerydata()
		},
		onReachBottom() {
			this.page++
			this.getQuerydata()
			console.log("触底加载")
		},
		methods: {
			getQuerydata() { //获取查询结果
				var params = {
					do: "collector",
					op: "reserveSearch",
					collectorid: uni.getStorageSync("collectorid"),
					type: this.type,
					start: this.startDate,
					end: this.endDate,
					page: "",
					psize: "",
				}
				util.requestWithSign(params).then(res => {
					console.log("查询到的结果", res)
					this.resultData = res.data
					this.list = this.list.concat(res.data.list)
					this.resultData.list = this.list
					if(res.data.total==this.resultData.list.length){//数据已经加载完
						return this.hasMore = false
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.packOrder {
		.selectOrderList-date {
			text-align: center;
			padding: 30rpx 0;
			box-sizing: border-box;

			.time {
				color: #00b388;

			}

			.centerText {
				display: inline-block;
				margin: 0 20rpx;
				color: #818181;
			}
		}

		.selectOrderList-main {
			padding: 20rpx;
			box-sizing: border-box;

			.content {
				margin-top: 20rpx;
				background: #fff;
				border-radius: 20rpx;

				.endTime {
					padding: 20rpx;
					box-sizing: border-box;
					border-bottom: 2rpx solid #f6f6f6;
				}

				.selectOrderList-center {
					padding: 20rpx;
					border-bottom: 2rpx solid #f6f6f6;
					box-sizing: border-box;

					.listItems {
						padding-top: 20rpx;
						text-align: center;

						.line {
							color: #f2f2f2;
						}
					}

					.tobePacked-type {
						margin-top: 35rpx;

						// border: 1px solid #000;
						.type-title {
							font-weight: bold;
						}

						.type-content {
							font-size: 25rpx;
							color: #868686;
							margin-top: 20rpx;
							display: flex;

							.num {
								color: #666666;
								font-weight: bold;
							}

							.content-number {
								margin-right: 30rpx;
							}
						}
					}
				}

				.finishedMain-type-footer {
					padding: 30rpx 20rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;

					.finishedMain-total {
						.finishedMain-title {}

						.value {
							font-weight: bold;
							color: #00b388;
						}
					}
				}
			}
		}
	}
</style>